package com.goldcn.user.controller;

import com.goldcn.user.model.HotWord;
import com.goldcn.user.service.HotWordeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by 1111 on 2016/12/6.
 */
@Api(value = "热词管理")
@RestController
@RequestMapping(value = "/hotWord")
public class HotWordController {
    @Autowired
    HotWordeService hotWordeService;

    @ApiOperation(value = "新增热词")
    @RequestMapping(method = RequestMethod.POST)
    public Object addHotWord(@RequestBody HotWord hotWord){
        return hotWordeService.addOrUpdateWord(hotWord,1);
    }

    @ApiOperation(value = "修改热词")
    @RequestMapping(method = RequestMethod.PUT)
    public Object updateHotWord(@RequestBody HotWord hotWord){
        return hotWordeService.addOrUpdateWord(hotWord,2);
    }

    @ApiOperation(value = "查看热词列表")
    @RequestMapping(method = RequestMethod.GET)
    public Object selectAll(){
        return hotWordeService.selectAll();
    }

    @ApiOperation(value = "删除热词")
    @RequestMapping(value = "/{id}",method = RequestMethod.DELETE)
    public Object deleteHotWord(@PathVariable Long id){
        return hotWordeService.deleteWord(id);
    }
}
